<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('留言板列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>标题：</label>
                            <input type="text" name="mbTopic"/>
                        </li>
                        <li>
                            <label>留言类型：</label>
                            <select name="mbType" th:with="type=${@dict.getType('mbs_message_board_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>处理状态：</label>
                            <select name="disposeStatus" th:with="type=${@dict.getType('mbs_dispose_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>处理等级：</label>
                            <select name="disposeLevel" th:with="type=${@dict.getType('mbs_dispose_level')}">
                                <option value="">所有</option>
                                <option value="-1">未分配</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>业务员：</label>
                            <select name="disposer">
                                <option value="">所有</option>
                                <option value="-1">未分配</option>
                                <option th:each="user : ${disposer}" th:text="${user.userName}"
                                        th:value="${user.userId}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="mbs:mbinfo:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var detailFlag = [[${@permission.hasPermi('mbs:mbinfo:detail')}]];
    var editFlag = [[${@permission.hasPermi('mbs:mbinfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('mbs:mbinfo:remove')}]];
    var disposeFlag = [[${@permission.hasPermi('mbs:dispose:status')}]];
    var disposeContentFlag = [[${@permission.hasPermi('mbs:dispose:content:status')}]];
    var mbTypeDatas = [[${@dict.getType('mbs_message_board_type')}]];
    var dLevelDatas = [[${@dict.getType('mbs_dispose_level')}]];
    var dStatusDatas = [[${@dict.getType('mbs_dispose_status')}]];
    var prefix = ctx + "mbs/mbinfo";
    var disposePrefix = ctx + "mbs/dispose";

    $(function () {
        var options = {
            url: prefix + "/verifier/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            detailUrl: prefix + "/detail/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "留言板",
            columns: [{
                checkbox: true
            },
                {
                    field: 'mbId',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'mbTopic',
                    title: '标题'
                },
                {
                    field: 'mbContent',
                    title: '内容',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, "open");
                    }
                },
                {
                    field: 'mbType',
                    title: '留言类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(mbTypeDatas, value);
                    }
                },
                {
                    field: 'disposeStatus',
                    title: '处理状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(dStatusDatas, value);
                    }
                },
                {
                    field: 'disposeLevel',
                    title: '处理等级',
                    formatter: function (value, row, index) {
                        if (value === '' || value === null) {
                            return '未分配等级';
                        }
                        return $.table.selectDictLabel(dLevelDatas, value);
                    }
                },
                {
                    field: 'disposer',
                    title: '业务员',
                    formatter: function (value, row, index) {
                        if (value === '' || value === null) {
                            return '未分配';
                        } else {
                            return value;
                        }
                    }
                },
                {
                    field: 'disposeContent',
                    title: '回复',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value, 10, "open");
                    }
                },
                {
                    field: 'createTime',
                    title: '提交时间'
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.mbId + '\')"><i class="fa fa-search"></i>详细</a>');
                        actions.push('<a class="btn btn-success btn-xs ' + disposeContentFlag + '" href="javascript:void(0)" onclick="disposeContent(\'' + row.mbId + '\')"><i class="fa fa-adjust"></i>回复</a>');
                        actions.push('<a class="btn btn-info btn-xs ' + disposeFlag + '" href="javascript:void(0)" onclick="dispose(\'' + row.mbId + '\')"><i class="fa fa-check"></i>已处理</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function dispose(mbId) {
        var url = disposePrefix + "/status";
        var data = {"mbId": mbId ,"disposeStatus": 1 };
        console.log(data);
        $.operate.post(url, data);
    }


    function disposeContent(mbId) {
        var url = disposePrefix + "/reply?mbId=" + mbId;
        $.modal.open("回复",url,300,300);
    }
</script>
</body>
</html>